//
//  TLItdManger.m
//  FunnyVideo
//
//  Created by 李鑫 on 15/10/12.
//  Copyright © 2015年 NewEggTech. All rights reserved.
//

#import "TLItdManger.h"
#import "AppDelegate.h"
#import "TLItdViewController.h"
#import "CALayer+Transition.h"

typedef void(^flipCompletionBlock)(void);

@interface TLItdManger ()
@property (nonatomic,strong) flipCompletionBlock flipCompletionBlock;
@end

@implementation TLItdManger
+ (TLItdManger *)sharedManger{
    static dispatch_once_t onceToken;
    static TLItdManger     *manger;
    dispatch_once(&onceToken, ^{
        manger = [[TLItdManger alloc] init];
    });
    
    return manger;
}

- (id)init{
    
    self = [super init];
    
    if(self)
    {
        self.itdViewCtrller = [[TLItdViewController alloc]
                               initWithImageNames:@[@"ItdImg_1",@"ItdImg_2",@"ItdImg_3",@"ItdImg_4"] flipActionBlock:^(NSUInteger pageNum) {
                                   NSLog(@"Flip once %lu",(unsigned long)pageNum);
                               } completionBlock:^{
                                   self.flipCompletionBlock();
                               }];
    }
    
    return self;
}

+ (BOOL)needShowIntroductionController{
    return NO;
}

- (void)showItdViewController:(UIViewController *)nxtViewController completionBlock:(void(^)(void))flipCompletion{
    
    self.flipCompletionBlock = flipCompletion;
    
    [[AppDelegate sharedLaunchAniWindow] setRootViewController:(UIViewController *)[[TLItdManger sharedManger] itdViewCtrller]];
    
    [[AppDelegate sharedLaunchAniWindow] makeKeyAndVisible];
    
}
@end
